package com.qida.clm.core.network.intercept;

import android.util.Log;

public class ErrorCodeProcessManager {
	private static final String TAG = ErrorCodeProcessManager.class.getSimpleName();
	private AbsProcessIntercept mProcessIntercept;
	private static ErrorCodeProcessManager sInstance = new ErrorCodeProcessManager();
	private ErrorCodeProcessManager(){}

	public static ErrorCodeProcessManager getInstance(){
		return sInstance;
	}

	/**
	 * 添加错误的处理者
	 * @param handler
	 */
	public void addProcess(AbsProcessIntercept handler){
		if(mProcessIntercept == null){
			mProcessIntercept = handler;
		} else {
			mProcessIntercept.setNext(handler);
		}
	}
	
	public boolean processErrorCode(int errorCode){
		boolean isProcess = false;
		if(mProcessIntercept != null){
			isProcess = mProcessIntercept.processErrorCode(errorCode);
		}
		if(!isProcess){
			Log.i(TAG, "Not find error process people.");
		}
		return isProcess;
	}
}